package com.ruyuan2020.im.design.mementopattern.use;
// TextDocument.java - 原发起人，负责创建备忘录和管理状态
public class TextDocument {
    private String content;

    public TextDocument() {
        this.content = "";
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getContent() {
        return content;
    }

    // 创建备忘录，保存当前状态
    public Memento saveToMemento() {
        return new Memento(content);
    }

    // 恢复状态，从备忘录中恢复
    public void restoreFromMemento(Memento memento) {
        this.content = memento.getContent();
    }
}
